<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 面向过程  面向对象

    function Point(x, y) {
        // {}
        // {}[[Prototype]] = Point.prototype;
        // this -> {}

        this.x = x;
        this.y = y;

        // return this;
    }

    // prototype => 原型对象 =>存放所有实例化对象共有的属性和方法
    // Point.prototype = {constructor:Point}

    Point.prototype.toString = function () { // (x,y)
        // this -> 调用此方法的实例化对象
        return `(${this.x},${this.y})`;
    }

    // 构造函数   
    var p1 = new Point(10, 20);
    console.log(p1);
    console.log(p1.x, p1.y);
    console.log(p1.toString());;
    console.log(p1.constructor === Point);

</script>

</html>